package com.casestudy.projectscheduler.view;

import java.io.Serializable;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.casestudy.projectscheduler.dto.ProjectDto;
import com.casestudy.projectscheduler.services.ProjectServices;

@Component @Scope(value="session")
public class ProjectBean implements Serializable {

    private static final long serialVersionUID = -2403138958014741653L;
    private String name;
    
    @Autowired
    private ProjectServices projectServices;
    
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    
    public ProjectServices getProjectServices() {
		return projectServices;
	}

	public void setProjectServices(ProjectServices projectServices) {
		this.projectServices = projectServices;
	}

	public List<ProjectDto> getProjectsList() {
    	List<ProjectDto> projectsList = loadProjects();
    	return projectsList;
    }
    
    public List<ProjectDto> loadProjects() {
    	List<ProjectDto> projectsList = getProjectServices().getProjects();
    	return projectsList;
    }
}
